use super::{delta::DeltaApplier, multiarch::CrossArchInstaller};

impl LinglongInstaller {
    /// 支持增量更新安装
    pub async fn install_update(
        &self,
        base_pkg: &str,
        delta_pkg: &str,
        public_key: &Path,
    ) -> Result<(), AppError> {
        let temp_dir = tempfile::tempdir()?;
        DeltaApplier::apply_delta(
            Path::new(base_pkg),
            Path::new(delta_pkg),
            &temp_dir.path(),
            public_key,
        )?;
        
        // 执行标准安装流程
        self.install(temp_dir.path().to_str().unwrap()).await
    }

    /// 跨架构安装
    pub async fn install_cross_arch(
        &self,
        pkg_path: &str,
        target_arch: &str,
        output_dir: &Path,
    ) -> Result<(), AppError> {
        let converted_pkg = CrossArchInstaller::convert_package(
            Path::new(pkg_path),
            output_dir,
            target_arch,
        )?;
        
        self.install(converted_pkg.to_str().unwrap()).await
    }
}